<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="css/bootstrap-table.min.css">
    <link rel="stylesheet" href="css/bootstrap-editable.css">
    <link rel="stylesheet" href="assets/index.css">
    <!--    <script src="assets/index.js"></script>
        <script src="assets/ga.js"></script>-->
    <script src="js/vue1.js"></script>
    <script src="js/axios.js"></script>
    <script src="assets/jquery.min.js"></script>
    <script src="assets/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/bootstrap.min1.css">
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="css/style.css"/>

    <link rel="stylesheet" href="css/bootstrap-datetimepicker.css"/>
    <!-- bootstrap-datetimepicker插件CSS-->

    <!-- Latest compiled and minified JavaScript -->
    <script src="js/bootstrap-table.min.js"></script>

    <!-- Latest compiled and minified Locales -->
    <script src="js/bootstrap-table-zh-CN.min.js"></script>


    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/json2/20140204/json2.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js "></script>
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"
            integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

    <![endif]-->
    <title>warning</title>
    <style>

        hr{
           margin-top: 5px;
           width: 98%;

        }

    </style>
</head>
<body>
<div class="cont" style="height: 99.9vh;overflow-y: scroll;overflow-x: hidden; width: 100%;">

<p id="pId" style="height:100%;margin-top: 20px;margin-left:5px;text-align: left;font-size: 1.1em;white-space: nowrap;line-height:20px"></p>
</div>

</body>
<script type="text/javascript">
    window.onload = function(){

        var urltoken=parent.location.search;
        var token1;
        token1=urltoken.substring(7);
        if(token1!="") {
            sessionStorage.token = token1;
        }
        $.ajax({
            url: "http://cjl3.rokyinfo.net:7110/v1.0/alarmmessage?page=1&limit=100&sidx=id&order=desc",
            method: "get",
            contentType: "application/json; charset=utf-8",
            cache: false,
            beforeSend: function (xhr) {
                /* Authorization header */
                xhr.setRequestHeader("Authorization",sessionStorage.token);
            },
            success: function (res) {

                var map = {},
                    dest = [];
                for(var i=0;i<res.data.list.length;i++) {
                    var s = res.data.list[i].alarmTime;
                    var ai = res.data.list[i];
                    var alaremst;

                    if(res.data.list[i].alarmType==0){
                        alaremst="故障告警";
                        car="img/Group 87.png"
                    }
                    else if(res.data.list[i].alarmType==4){
                        alaremst="断电告警";
                        car="img/Group 59.png"
                    }
                    else if(res.data.list[i].alarmType==2){
                        alaremst="内置电池低告警";
                        car="img/Group 17.png"
                    }
                    else{
                        alaremst="震动告警";
                        car="img/Group 17.png"
                    }
                    mm="<a style='text-decoration: none;cursor:pointer;' id='"+res.data.list[i].ccuSn+"' onclick='showMessage(this)'>"+res.data.list[i].applicant+"&nbsp;(&nbsp;"+res.data.list[i].phoneNumber+"&nbsp;)"+"</a>"+"发生"+alaremst;

                    oo=res.data.list[i].alarmTime.substring(11, 19);
                    if (!map[s.substring(0, 10)]) {
                        $("p").append("&nbsp;&nbsp;&nbsp;"+s.substring(0, 10)+'<hr>');
                        $("p").append("&nbsp;&nbsp;&nbsp;"+"<img  src='"+car+"' width='25px' height='25px'>"+"&nbsp;&nbsp;"+mm+"<br/>");

                        $("p").append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+oo+"<br/>");
                        $("p").append("<br/>");

                        dest.push({
                            riqi: s.substring(0, 10),

                            data: [ai]
                        });

                        map[s.substring(0, 10)] = ai;



                    }
                    else{

                        $("p").append("&nbsp;&nbsp;&nbsp;"+"<img  src='"+car+"' width='25px' height='25px'>"+"&nbsp;&nbsp;"+mm+"<br/>");
                        $("p").append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+oo+"<br/>");

                        $("p").append("<br/>");
                    }

                }




            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.log("失败");
                console.log(jqXHR);
            }
        })

       setInterval("publicBusi()",10000);


    };

    function publicBusi(){

        $.ajax({
            url: "http://cjl3.rokyinfo.net:7110/v1.0/alarmmessage?page=1&limit=100&sidx=id&order=desc",
            method: "get",
            contentType: "application/json; charset=utf-8",
            cache: false,
            beforeSend: function (xhr) {
                /* Authorization header */
                xhr.setRequestHeader("Authorization",sessionStorage.token);
            },
            success: function (res) {
                $('#pId').html('')
                var map = {},
                    dest = [];
                for(var i=0;i<res.data.list.length;i++) {
                    var s = res.data.list[i].alarmTime;
                    var ai = res.data.list[i];
                    var alaremst;

                    if(res.data.list[i].alarmType==0){
                        alaremst="故障告警";
                        car="img/Group 87.png"
                    }
                    else if(res.data.list[i].alarmType==4){
                        alaremst="断电告警";
                        car="img/Group 59.png"
                    }
                    else if(res.data.list[i].alarmType==2){
                        alaremst="内置电池低告警";
                        car="img/Group 17.png"
                    }
                    else{
                        alaremst="震动告警";
                        car="img/Group 17.png"
                    }
                    mm="<a style='text-decoration: none;cursor:pointer;' id='"+res.data.list[i].ccuSn+"' onclick='showMessage(this)'>"+res.data.list[i].applicant+"&nbsp;(&nbsp;"+res.data.list[i].phoneNumber+"&nbsp;)"+"</a>"+"发生"+alaremst;

                    oo=res.data.list[i].alarmTime.substring(11, 19);
                    if (!map[s.substring(0, 10)]) {
                        $("p").append("&nbsp;&nbsp;&nbsp;"+s.substring(0, 10)+'<hr>');
                        $("p").append("&nbsp;&nbsp;&nbsp;"+"<img  src='"+car+"' width='25px' height='25px'>"+"&nbsp;&nbsp;"+mm+"<br/>");

                        $("p").append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+oo+"<br/>");
                        $("p").append("<br/>");

                        dest.push({
                            riqi: s.substring(0, 10),

                            data: [ai]
                        });

                        map[s.substring(0, 10)] = ai;



                    }
                    else{

                        $("p").append("&nbsp;&nbsp;&nbsp;"+"<img  src='"+car+"' width='25px' height='25px'>"+"&nbsp;&nbsp;"+mm+"<br/>");
                        $("p").append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+oo+"<br/>");

                        $("p").append("<br/>");
                    }

                }




            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.log("失败");
                console.log(jqXHR);
            }
        })
    }

    function showMessage(ojb){

        var index_str = ojb.id;
        var id = index_str.substring(index_str.lastIndexOf("-")+1,index_str.length);

        window.parent.warnsn = id;
        sessionStorage.id=id;

        $.ajax({
            url: "http://cjl3.rokyinfo.net:7110/v1.0/ebike?page=1&limit=20&sidx=id&order=desc&ccuSn="+id,
            method: "get",
            contentType: "application/json; charset=utf-8",
            cache: false,
            beforeSend: function (xhr) {
                /* Authorization header */
                xhr.setRequestHeader("Authorization", sessionStorage.token);
            },

            success: function (res) {
                console.log(res);

                sessionStorage.daoqi=res.data.list[0].simValidityTime;
                window.parent.lon1 = res.data.list[0].lon;
                window.parent.lat1 = res.data.list[0].lat;
                window.parent.pointjump();
                sessionStorage.jingdu = res.data.list[0].lon;
                sessionStorage.weidu = res.data.list[0].lat;
                sessionStorage.shangbao = res.data.list[0].reportTime;
                sessionStorage.chezai = res.data.list[0].bmsSoh-100;
//                var v;
//                if(res.data.list[0].dcuVbat==0){
//                    v="0"
//                }
//                else if(res.data.list[0].dcuVbat==3){
//                    v="33%"
//                }
//                else if(res.data.list[0].dcuVbat==6){
//                    v="66%"
//                }
//                else if(res.data.list[0].dcuVbat==9){
//                    v="99%"
//                }
                sessionStorage.neizhi = res.data.list[0].dcuVbat;
                sessionStorage.jizhan = res.data.list[0].dcuGsmRssi;
                sessionStorage.weixing = res.data.list[0].dcuGpsRssi;
                sessionStorage.weizhi = res.data.list[0].lon+res.data.list[0].lat;
                var q;
                if(res.data.list[0].status==0){
                    q="设防"
                }
                else if(res.data.list[0].status==1){
                    q="撤防"
                }
                else if(res.data.list[0].status==2){
                    q="P档"
                }
                else if(res.data.list[0].status==3){
                    q="骑行"
                }
                else{
                    q="状态不明"
                }
                sessionStorage.zhuangtai=q;


            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.log("失败2");
                console.log(jqXHR);
            }
        });
        $.ajax({
            url: "http://cjl3.rokyinfo.net:7110/v1.0/orders?page=1&limit=20&sidx=id&order=desc&belong=1&ccuSn="+id,
            method: "get",
            contentType: "application/json; charset=utf-8",
            cache: false,
//            beforeSend: function (xhr) {
//                /* Authorization header */
//                xhr.setRequestHeader("Authorization", sessionStorage.token);
//            },

            success: function (res) {

                console.log(res);
                sessionStorage.Sn=res.data.list[0].ccuSn;
                sessionStorage.riqi1=res.data.list[0].buyTime;
                sessionStorage.pinpai=res.data.list[0].brand;
                sessionStorage.xinghao=res.data.list[0].model;
                sessionStorage.chejia=res.data.list[0].vin;
                sessionStorage.jinee=res.data.list[0].buyPrice;
                sessionStorage.invoice=res.data.list[0].billImg;
                if(res.data.list[0].city==null||res.data.list[0].city=="null"){
                    var ssq2=res.data.list[0].province
                }
                else if(res.data.list[0].district==null||res.data.list[0].district=="null"){
                    var ssq2=res.data.list[0].province+res.data.list[0].city
                }else {
                    var ssq2=res.data.list[0].province+res.data.list[0].city+res.data.list[0].district
                }
                sessionStorage.shengshi=ssq2;
                sessionStorage.carpic2=res.data.list[0].scooterImg[1];
                sessionStorage.carpic1=res.data.list[0].scooterImg[0];
                sessionStorage.xingming=res.data.list[0].applicant;
                sessionStorage.shenfen=res.data.list[0].idNumber;
                sessionStorage.shouji=res.data.list[0].phoneNumber;

            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.log("失败1")
                console.log(jqXHR);
            }
        });

        window.parent.changesn2();
        parent.rightFrame2.location.href="righttable.html";


    }





</script>
</html>